package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.common.service.TableService;
import com.ruoyi.logistic.domain.NetworkUndertakePayroll;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.logistic.domain.vo.NetworkUndertakePayrollVo;
import com.ruoyi.logistic.service.NetworkUndertakePayrollService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/network/undertakePayRoll")
@RestController
@Api(tags = "网点财务_承/业工资表")
public class NetworkUndertakePayrollController {
    @Autowired
    private NetworkUndertakePayrollService networkUndertakePayrollService;
    @Autowired
    private TableService tableService;

    @ApiOperation("网点承业工资表")
    @PostMapping("/search")
    public R search(@RequestBody NetworkUndertakePayrollVo vo){
        List<NetworkUndertakePayroll> list = networkUndertakePayrollService.search(vo);
        List<TableVo> fieldList = tableService.getFieldAnnotation(new NetworkUndertakePayroll());
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        jsonObject.put("list", PageInfo.info(list));
        jsonObject.put("fields", fieldList);
        if (list == null || list.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(jsonObject);
        }
    }
}
